﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Drawing;
using PdfSharp;
using PdfSharp.Drawing;
using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;

/// <summary>
/// Summary description for MyPDF
/// </summary>
/// 
namespace CE.CarInsurance
{
    public class EtiqaCarInsurancePDFOutput
    {

        private string _proposalId;
        public string ProposalId
        {
            get { return _proposalId; }
            set { _proposalId = value; }
        }

        private string _schedulewritingpagetitle;// "Etiqa - Schedule Writing";
        public string ScheduleWritingPageTitle
        {
            get { return _schedulewritingpagetitle; }
            set { _schedulewritingpagetitle = value; }
        }

        private string _certificatepagetitle;// "Etiqa - Certificate Of Insurance";
        public string CertificatePageTitle
        {
            get { return _certificatepagetitle; }
            set { _certificatepagetitle = value; }
        }

        private string _taxinvoicepagetitle;// "Etiqa - Tax";
        public string TaxInvoicePageTitle
        {
            get { return _taxinvoicepagetitle; }
            set { _taxinvoicepagetitle = value; }
        }

        #region promo
        private string _20percentpromo; //12dec2011 etiqa promo
        public string Etiqa20PercentPromo
        {
            get { return _20percentpromo; }
            set { _20percentpromo = value; }
        }

        private string _discountedpremium;
        public string DiscountedPremium
        {
            get { return _discountedpremium; }
            set { _discountedpremium = value; }
        }

        private string _promodiscount;
        public string PromoDiscount
        {
            get { return _promodiscount; }
            set { _promodiscount = value; }
        }
        #endregion


        #region Customer Profile
        string _customerName;// "BRYAN YU CHEE SIANG";
        public string CustomerName
        {
            get { return _customerName; }
            set { _customerName = value; }
        }

        string _customerAddress1;// "123, JALAN 222";
        public string CustomerAddress1
        {
            get { return _customerAddress1; }
            set { _customerAddress1 = value; }
        }

        string _customerAddress2;// "SINGAPORE 604565";
        public string CustomerAddress2
        {
            get { return _customerAddress2; }
            set { _customerAddress2 = value; }
        }

        string _driverNameList;
        public string DriverNameList
        {
            get { return _driverNameList; }
            set { _driverNameList = value; }
        }
        #endregion

        #region Schedule Writing Variables
        string _agency;// "001045";
        public string Agency
        {
            get { return _agency; }
            set { _agency = value; }
        }

        string _classOfPolicy;// "MOTOR PRIVATE CAR";
        public string ClassOfPolicy
        {
            get { return _classOfPolicy; }
            set { _classOfPolicy = value; }
        }

        string _policyNumber;// "DMAP105004354";
        public string PolicyNumber
        {
            get { return _policyNumber; }
            set { _policyNumber = value; }
        }

        string _account;// "001045";
        public string Account
        {
            get { return _account; }
            set { _account = value; }
        }

        string _issuedOn;// DateTime.Now.Day.ToString("00") + "/" + DateTime.Now.Month.ToString("00") + "/" + DateTime.Now.Year.ToString("0000") + " in SINGAPORE";
        public string IssuedOn
        {
            get { return _issuedOn; }
            set { _issuedOn = value; }
        }

        string _replacePolicyNumber;// "DMAP095006346";
        public string ReplacePolicyNumber
        {
            get { return _replacePolicyNumber; }
            set { _replacePolicyNumber = value; }
        }

        string _client;// "";
        public string Client
        {
            get { return _client; }
            set { _client = value; }
        }

        string _acceptanceDate;// DateTime.Now.Day.ToString("00") + "/" + DateTime.Now.Month.ToString("00") + "/" + DateTime.Now.Year.ToString("0000");
        public string AcceptanceDate
        {
            get { return _acceptanceDate; }
            set { _acceptanceDate = value; }
        }

        string _startPeriod;//DateTime.Now.Day.ToString("00") + "/" + DateTime.Now.Month.ToString("00") + "/" + DateTime.Now.Year.ToString("0000");
        public string PeriodInsuranceStart
        {
            get { return _startPeriod; }
            set { _startPeriod = value; }
        }

        string _endPeriod;//(DateTime.Now.Day - 1).ToString("00") + "/" + DateTime.Now.Month.ToString("00") + "/" + (DateTime.Now.Year + 1).ToString("0000");
        public string PeriodInsuranceEnd
        {
            get { return _endPeriod; }
            set { _endPeriod = value; }
        }

        string _basicPremiumAmount;// "S$1,529.55";
        public string BasicPremiumAmount
        {
            get { return _basicPremiumAmount; }
            set { _basicPremiumAmount = value; }
        }

        string _lessNCDPercent;// "50.00%";
        public string LessNCDPercent
        {
            get { return _lessNCDPercent; }
            set { _lessNCDPercent = value; }
        }

        string _lessAWSAmount;
        public string LessAWSAmount
        {
            get { return _lessAWSAmount; }
            set { _lessAWSAmount = value; }
        }

        string _additionalCharge;
        public string AdditionalCharge
        {
            get { return _additionalCharge; }
            set { _additionalCharge = value; }
        }


        bool _isOFD;
        public bool IsOFD
        {
            get { return _isOFD; }
            set { _isOFD = value; }
        }

        string _lessOFDAmount;// "S$764.78-";
        public string LessOFDAmount
        {
            get { return _lessOFDAmount; }
            set { _lessOFDAmount = value; }
        }

        string _ofdPercent;
        public string OFDPercent
        {
            get { return _ofdPercent; }
            set { _ofdPercent = value; }
        }

        string _lessNCDAmount;// "S$764.78-";
        public string LessNCDAmount
        {
            get { return _lessNCDAmount; }
            set { _lessNCDAmount = value; }
        }

        bool _isNCDProtector;
        public bool IsNCDProtector
        {
            get { return _isNCDProtector; }
            set { _isNCDProtector = value; }
        }

        string _ncdProtectionPremiumPercent;// "10%";
        public string NCDProtectionPremiumPercent
        {
            get { return _ncdProtectionPremiumPercent; }
            set { _ncdProtectionPremiumPercent = value; }
        }

        string _ncdProtectionPremiumAmount;// "S$76.48";
        public string NCDProtectionPremiumAmount
        {
            get { return _ncdProtectionPremiumAmount; }
            set { _ncdProtectionPremiumAmount = value; }
        }

        string _totalAnnualPermium;// "S$841.25";
        public string TotalAnnualPermium
        {
            get { return _totalAnnualPermium; }
            set { _totalAnnualPermium = value; }
        }

        string _premiumDue;// "S$841.25";
        public string PremiumDue
        {
            get { return _premiumDue; }
            set { _premiumDue = value; }
        }

        string _premiumGST;// "S$58.89";
        public string PremiumGST
        {
            get { return _premiumGST; }
            set { _premiumGST = value; }
        }

        string _totalDueSchedule;// "S$900.14";
        public string TotalDueSchedule
        {
            get { return _totalDueSchedule; }
            set { _totalDueSchedule = value; }
        }

        string _totalDueInvoice;// "S$900.14";
        public string TotalDueInvoice
        {
            get { return _totalDueInvoice; }
            set { _totalDueInvoice = value; }
        }


        string _occupation;// "INDOOR - IT";
        public string Occupation
        {
            get { return _occupation; }
            set { _occupation = value; }
        }

        string _registrationNo;// "SGU5007E";
        public string RegistrationNo
        {
            get { return _registrationNo; }
            set { _registrationNo = value; }
        }

        string _makeModel;// "MITSUBISHI LANCER 1.6M";
        public string MakeModel
        {
            get { return _makeModel; }
            set { _makeModel = value; }
        }

        string _typeOfCover;// "Comprehensive";
        public string TypeOfCover
        {
            get { return _typeOfCover; }
            set { _typeOfCover = value; }
        }

        string _noOfSeats;// "5";
        public string NoOfSeats
        {
            get { return _noOfSeats; }
            set { _noOfSeats = value; }
        }

        string _bodyType;// "SALOON";
        public string BodyType
        {
            get { return _bodyType; }
            set { _bodyType = value; }
        }

        string _engineNo;// "4G18HY9061";
        public string EngineNo
        {
            get { return _engineNo; }
            set { _engineNo = value; }
        }

        string _capacity;// "1584";
        public string Capacity
        {
            get { return _capacity; }
            set { _capacity = value; }
        }

        string _regYear;// "2007";
        public string RegYear
        {
            get { return _regYear; }
            set { _regYear = value; }
        }

        string _chassisNo;// "JMYSNCS3A7U006848";
        public string ChassisNo
        {
            get { return _chassisNo; }
            set { _chassisNo = value; }
        }

        string _certificateRef;// "MX1";
        public string CertificateRef
        {
            get { return _certificateRef; }
            set { _certificateRef = value; }
        }

        string _excessNameDriverAmount;// "S$500.00";
        public string ExcessNameDriverAmount
        {
            get { return _excessNameDriverAmount; }
            set { _excessNameDriverAmount = value; }
        }

        string _excessUnNameDriverAmount;// "S$1,000.00";
        public string ExcessUnNameDriverAmount
        {
            get { return _excessUnNameDriverAmount; }
            set { _excessUnNameDriverAmount = value; }
        }

        string _hirePurchaseCompanyName;//DBS Bank
        public string HirePurchaseCompanyName
        {
            get { return _hirePurchaseCompanyName; }
            set { _hirePurchaseCompanyName = value; }
        }

        #endregion

        #region Certificate Variables
        string _certNumber;// "DMAP10S004354";
        public string CertificateNumber
        {
            get { return _certNumber; }
            set { _certNumber = value; }
        }

        /*
        string _vehicleNumber;// "SGU5007E";
        public string VehicleNumber
        {
            get { return _vehicleNumber; }
            set { _vehicleNumber = value; }
        }

        string _policyHolderName;// "TAN SWEE MENG";
        public string PolicyHolderName
        {
            get { return _policyHolderName; }
            set { _policyHolderName = value; }
        }
        

        string _effCommencementDate;// DateTime.Now.Day.ToString("00") + " " + DateTime.Now.ToString("MMM") + " " + DateTime.Now.Year.ToString("00");
        public string EffectiveCommencementDate
        {
            get { return _effCommencementDate; }
            set { _effCommencementDate = value; }
        }
        
        string _excessNameDriversAmount;// "S$500.00";
        public string ExcessNameDriversAmount
        {
            get { return _excessNameDriversAmount; }
            set { _excessNameDriversAmount = value; }
        }

        string _excessUnNameDriversAmount;// "S$1.000.00";
        public string ExcessUnNameDriversAmount
        {
            get { return _excessUnNameDriversAmount; }
            set { _excessUnNameDriversAmount = value; }
        }
        

        string _expiryDate;// (DateTime.Now.Day - 1).ToString("00") + " " + DateTime.Now.ToString("MMM") + " " + (DateTime.Now.Year + 1).ToString("00");
        public string ExpiryDate
        {
            get { return _expiryDate; }
            set { _expiryDate = value; }
        }
         * */
        #endregion

        #region Tax Invoice Variables
        string _gstRegNumber;// "M90363266Y";
        public string GSTRegNumber
        {
            get { return _gstRegNumber; }
            set { _gstRegNumber = value; }
        }

        string _transDate;// DateTime.Now.ToShortDateString();
        public string TransactionDate
        {
            get { return _transDate; }
            set { _transDate = value; }
        }
        /*
        string _typeOfPolicy;// "Car Insurance";
        public string TypeOfPolicy
        {
            get { return _typeOfPolicy; }
            set { _typeOfPolicy = value; }
        }

        string _coverPeriod;// "From 28/04/2010 to 27/04/2011 (both dates inclusive)";
        public string CoverPeriod
        {
            get { return _coverPeriod; }
            set { _coverPeriod = value; }
        }
        
        string _policyNumberTaxInvoice;// "DPMP0000001";
        public string PolicyNumberTaxInvoice
        {
            get { return _policyNumberTaxInvoice; }
            set { _policyNumberTaxInvoice = value; }
        }*/

        string _branchTerritory;// "SINGAPORE / Singapore";
        public string BranchTerritory
        {
            get { return _branchTerritory; }
            set { _branchTerritory = value; }
        }

        string _cardType; //VISA
        public string CardType
        {
            get { return _cardType; }
            set { _cardType = value; }
        }

        string _cardLastFourDigit; //1234
        public string CardLastFourDigit
        {
            get { return _cardLastFourDigit; }
            set { _cardLastFourDigit = value; }
        }
        #endregion

        private DateTime dateTimeNow = CE.Global.General.GetUTCDateTime();

        public EtiqaCarInsurancePDFOutput()
        {
            ClearFields();
        }

        public bool GenerateAllOuput(out string[] fileList)
        {
            fileList = new string[3];
            bool _retValue = false;
            try
            {
                fileList[0] = EtiqaTaxInvoiceOutputSample();
                fileList[1] = EtiqaCertificateOutputSample();
                fileList[2] = EtiqaScheduleOutputSample();
                _retValue = true;
            }
            catch (Exception Ex)
            {
                _retValue = false;
            }
          
            return _retValue;
        }

        public string EtiqaScheduleOutputSample()
        {
            // Create a new PDF document
            PdfDocument document = new PdfDocument();
            document.Info.Title = _schedulewritingpagetitle;

            // Create an empty page
            PdfPage page = document.AddPage();

            // Get an XGraphics object for drawing
            XGraphics gfx = XGraphics.FromPdfPage(page);

            //XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);

            // Create a font
            XFont font = new XFont("Verdana", 7, XFontStyle.Bold);
            XFont fontNormal = new XFont("Verdana", 7, XFontStyle.Regular);
            XColor _xcolor = new XColor();
            _xcolor.R = 0;
            _xcolor.G = 0;
            _xcolor.B = 0;
            System.Drawing.Rectangle _rect = new System.Drawing.Rectangle(20, 10, 500, 100);
            XPen _pen = new XPen(_xcolor);

            int curX = 50;
            int curY = 15;

            gfx.DrawImage(XImage.FromFile(AppDomain.CurrentDomain.BaseDirectory + "images\\pdf\\header_etiqa_01.png"), new XRect(curX, curY, 520, 61));
            curY += 55;

            gfx.DrawString("ORIGINAL", font, XBrushes.Black, new XRect(curX, curY, 520, 20), XStringFormat.TopLeft);
            gfx.DrawString("THE SCHEDULE", font, XBrushes.Black, new XRect(curX, curY, 520, 20), XStringFormat.TopCenter);
            curY += 10;
            gfx.DrawLine(new XPen(_xcolor), curX, curY, 565, curY);
            curY += 10;
            
            gfx.DrawString("Agency", fontNormal, XBrushes.Black, new XRect(curX, curY, 100, 20), XStringFormat.TopLeft);
            gfx.DrawString(_agency, fontNormal, XBrushes.Black, new XRect(curX + 50, curY, 100, 20), XStringFormat.TopLeft);
            gfx.DrawString("Class of Policy", fontNormal, XBrushes.Black, new XRect(curX + 150, curY, 150, 20), XStringFormat.TopLeft);
            gfx.DrawString(_classOfPolicy, fontNormal, XBrushes.Black, new XRect(curX + 220, curY, 100, 20), XStringFormat.TopLeft);
            gfx.DrawString("Policy Number", fontNormal, XBrushes.Black, new XRect(curX + 340, curY, 150, 20), XStringFormat.TopLeft);
            gfx.DrawString(_policyNumber, fontNormal, XBrushes.Black, new XRect(curX + 420, curY, 100, 20), XStringFormat.TopLeft);
            curY += 10;

            gfx.DrawString("Account", fontNormal, XBrushes.Black, new XRect(curX, curY, 100, 20), XStringFormat.TopLeft);
            gfx.DrawString(_account, fontNormal, XBrushes.Black, new XRect(curX + 50, curY, 100, 20), XStringFormat.TopLeft);
            gfx.DrawString("Issued On", fontNormal, XBrushes.Black, new XRect(curX + 150, curY, 150, 20), XStringFormat.TopLeft);
            gfx.DrawString(_issuedOn, fontNormal, XBrushes.Black, new XRect(curX + 220, curY, 100, 20), XStringFormat.TopLeft);
            gfx.DrawString("Replacing Policy No.", fontNormal, XBrushes.Black, new XRect(curX + 340, curY, 150, 20), XStringFormat.TopLeft);
            gfx.DrawString(_replacePolicyNumber, fontNormal, XBrushes.Black, new XRect(curX + 420, curY, 100, 20), XStringFormat.TopLeft);
            curY += 15;

            gfx.DrawString("Client", fontNormal, XBrushes.Black, new XRect(curX, curY, 100, 20), XStringFormat.TopLeft);
            gfx.DrawString(_client, fontNormal, XBrushes.Black, new XRect(curX + 50, curY, 100, 20), XStringFormat.TopLeft);
            gfx.DrawString("Acceptance Date", fontNormal, XBrushes.Black, new XRect(curX + 150, curY, 150, 20), XStringFormat.TopLeft);
            gfx.DrawString(_acceptanceDate, fontNormal, XBrushes.Black, new XRect(curX + 220, curY, 100, 20), XStringFormat.TopLeft);
            curY += 15;
            gfx.DrawLine(new XPen(_xcolor), curX, curY, 565, curY);
            curY += 10;

            gfx.DrawString("Period of Insurance from", fontNormal, XBrushes.Black, new XRect(curX, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString(_startPeriod + " to " + _endPeriod + " , both dates inclusive", fontNormal, XBrushes.Black, new XRect(curX + 150, curY, 200, 20), XStringFormat.TopLeft);
            curY += 15;
            gfx.DrawLine(new XPen(_xcolor), curX, curY, 565, curY);
            curY += 10;

            gfx.DrawString("Insured's Name", fontNormal, XBrushes.Black, new XRect(curX, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString(_customerName, fontNormal, XBrushes.Black, new XRect(curX + 150, curY, 200, 20), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawString("Address", fontNormal, XBrushes.Black, new XRect(curX, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString(_customerAddress1, fontNormal, XBrushes.Black, new XRect(curX + 150, curY, 200, 20), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawString(_customerAddress2, fontNormal, XBrushes.Black, new XRect(curX + 150, curY, 200, 20), XStringFormat.TopLeft);
            curY += 15;
            gfx.DrawLine(new XPen(_xcolor), curX, curY, 565, curY);
            curY += 10;

            gfx.DrawString("Business/Occupation", fontNormal, XBrushes.Black, new XRect(curX, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString(_occupation, fontNormal, XBrushes.Black, new XRect(curX + 150, curY, 200, 20), XStringFormat.TopLeft);
            curY += 15;
            gfx.DrawLine(new XPen(_xcolor), curX, curY, 565, curY);
            curY += 10;

            gfx.DrawString("Premium", fontNormal, XBrushes.Black, new XRect(curX, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString("Basic Annual Premium", fontNormal, XBrushes.Black, new XRect(curX + 150, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString(_basicPremiumAmount, fontNormal, XBrushes.Black, new XRect(curX + 300, curY, 200, 20), XStringFormat.TopLeft);
            curY += 10;

            gfx.DrawString("Less NCD", fontNormal, XBrushes.Black, new XRect(curX + 150, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString(_lessNCDPercent, fontNormal, XBrushes.Black, new XRect(curX + 250, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString(_lessNCDAmount + " [-]", fontNormal, XBrushes.Black, new XRect(curX + 300, curY, 200, 20), XStringFormat.TopLeft);
            curY += 10;

            if (_typeOfCover.Trim() == "2")
            {
                gfx.DrawString("Less AWS Discount", fontNormal, XBrushes.Black, new XRect(curX + 150, curY, 200, 20), XStringFormat.TopLeft);
                gfx.DrawString("15%", fontNormal, XBrushes.Black, new XRect(curX + 250, curY, 200, 20), XStringFormat.TopLeft);
                gfx.DrawString(_lessAWSAmount + " [-]", fontNormal, XBrushes.Black, new XRect(curX + 300, curY, 200, 20), XStringFormat.TopLeft);                
                curY += 10;
            }

            if (_isNCDProtector)
            {
                gfx.DrawString("NCD Protection Premium", fontNormal, XBrushes.Black, new XRect(curX + 150, curY, 200, 20), XStringFormat.TopLeft);
                gfx.DrawString(_ncdProtectionPremiumPercent, fontNormal, XBrushes.Black, new XRect(curX + 250, curY, 200, 20), XStringFormat.TopLeft);
                gfx.DrawString(_ncdProtectionPremiumAmount + " [+]", fontNormal, XBrushes.Black, new XRect(curX + 300, curY, 200, 20), XStringFormat.TopLeft);
                curY += 10;
            }

            if (_isOFD)
            {
                gfx.DrawString("Demerit Free Discount ", fontNormal, XBrushes.Black, new XRect(curX + 150, curY, 200, 20), XStringFormat.TopLeft);
                gfx.DrawString(_ofdPercent , fontNormal, XBrushes.Black, new XRect(curX + 250, curY, 200, 20), XStringFormat.TopLeft);
                gfx.DrawString(_lessOFDAmount + " [-]", fontNormal, XBrushes.Black, new XRect(curX + 300, curY, 200, 20), XStringFormat.TopLeft);
                curY += 10;
            }

            if (_driverNameList != String.Empty)
            { 
                string[] _ArrNameList = _driverNameList.Split(';');                
                if (_ArrNameList.Length > 1)
                {
                    int AdditionalDriverCharge = 20 * (_ArrNameList.Length - 1);

                    gfx.DrawString("Additional Charges  ", fontNormal, XBrushes.Black, new XRect(curX + 150, curY, 200, 20), XStringFormat.TopLeft);
                    gfx.DrawString("S$ " + AdditionalDriverCharge.ToString() + ".00" + " [+]", fontNormal, XBrushes.Black, new XRect(curX + 300, curY, 200, 20), XStringFormat.TopLeft);
                    curY += 10;
                }
            }

            gfx.DrawString("Total Annual Premium", fontNormal, XBrushes.Black, new XRect(curX + 150, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString(_totalAnnualPermium, fontNormal, XBrushes.Black, new XRect(curX + 300, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString("Premium Due", fontNormal, XBrushes.Black, new XRect(curX + 370, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString(_premiumDue, fontNormal, XBrushes.Black, new XRect(curX + 440, curY, 200, 20), XStringFormat.TopLeft);
            curY += 10;

            gfx.DrawString("Premium GST", fontNormal, XBrushes.Black, new XRect(curX + 370, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString(_premiumGST, fontNormal, XBrushes.Black, new XRect(curX + 440, curY, 200, 20), XStringFormat.TopLeft);


            if (_20percentpromo != "" && _20percentpromo == "20discount")
            {
                curY += 10;
                gfx.DrawString("20% FESTIVE", fontNormal, XBrushes.Black, new XRect(curX + 370, curY, 200, 20), XStringFormat.TopLeft);
                curY += 10;
                gfx.DrawString("promo discount", fontNormal, XBrushes.Black, new XRect(curX + 370, curY, 200, 20), XStringFormat.TopLeft);
                gfx.DrawString(_promodiscount + " [-]", fontNormal, XBrushes.Black, new XRect(curX + 440, curY, 200, 20), XStringFormat.TopLeft);
                curY += 10;
                gfx.DrawString("Total Due", fontNormal, XBrushes.Black, new XRect(curX + 370, curY, 200, 20), XStringFormat.TopLeft);
                gfx.DrawString(_discountedpremium, fontNormal, XBrushes.Black, new XRect(curX + 440, curY, 200, 20), XStringFormat.TopLeft);
            }
            else
            {
                curY += 10;
                gfx.DrawString("Total Due", fontNormal, XBrushes.Black, new XRect(curX + 370, curY, 200, 20), XStringFormat.TopLeft);
                gfx.DrawString(_totalDueSchedule, fontNormal, XBrushes.Black, new XRect(curX + 440, curY, 200, 20), XStringFormat.TopLeft);
            }
            curY += 15;

            gfx.DrawLine(new XPen(_xcolor), curX, curY, 565, curY);
            curY += 10;

            gfx.DrawString("Risk No. 001", fontNormal, XBrushes.Black, new XRect(curX, curY, 200, 20), XStringFormat.TopLeft);

            int newX = curX;
            int _indent = 5;

            newX += _indent;
            gfx.DrawString(_classOfPolicy, fontNormal, XBrushes.Black, new XRect(curX + 150, curY, 200, 20), XStringFormat.TopLeft);
            curY += 10;

            gfx.DrawString("1.", fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);

            //_indent += 5;
            newX += _indent;
            newX += _indent;

            gfx.DrawString("Registration", fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString(_registrationNo, fontNormal, XBrushes.Black, new XRect(curX + 150, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString("Make/Model", fontNormal, XBrushes.Black, new XRect(curX + 250, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString(_makeModel, fontNormal, XBrushes.Black, new XRect(curX + 300, curY, 200, 20), XStringFormat.TopLeft);
            curY += 10;

            gfx.DrawString("Type of Cover", fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);
            //gfx.DrawString(_typeOfCover, fontNormal, XBrushes.Black, new XRect(curX + 150, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString("Comprehensive", fontNormal, XBrushes.Black, new XRect(curX + 150, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString("No. of Seats", fontNormal, XBrushes.Black, new XRect(curX + 250, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString(_noOfSeats, fontNormal, XBrushes.Black, new XRect(curX + 310, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString("Body Type", fontNormal, XBrushes.Black, new XRect(curX + 370, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString(_bodyType, fontNormal, XBrushes.Black, new XRect(curX + 430, curY, 200, 20), XStringFormat.TopLeft);
            curY += 10;

            gfx.DrawString("Engine No.", fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString(_engineNo, fontNormal, XBrushes.Black, new XRect(curX + 150, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString("Capacity cc's", fontNormal, XBrushes.Black, new XRect(curX + 250, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString(_capacity, fontNormal, XBrushes.Black, new XRect(curX + 310, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString("Year of Regn", fontNormal, XBrushes.Black, new XRect(curX + 370, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString(_regYear, fontNormal, XBrushes.Black, new XRect(curX + 430, curY, 200, 20), XStringFormat.TopLeft);
            curY += 10;

            gfx.DrawString("Chassis No.", fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString(_chassisNo, fontNormal, XBrushes.Black, new XRect(curX + 150, curY, 200, 20), XStringFormat.TopLeft);
            curY += 10;

            gfx.DrawString("Certificate Ref.", fontNormal, XBrushes.Black, new XRect(curX + 370, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString(_certificateRef, fontNormal, XBrushes.Black, new XRect(curX + 430, curY, 200, 20), XStringFormat.TopLeft);
            curY += 10;

            gfx.DrawString("Excess : Named Drivers", fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);

            
            gfx.DrawString(_excessNameDriverAmount, fontNormal, XBrushes.Black, new XRect(curX + 200, curY, 200, 20), XStringFormat.TopLeft);
            curY += 10;

            gfx.DrawString("Excess : UnNamed Drivers", fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString(_excessUnNameDriverAmount, fontNormal, XBrushes.Black, new XRect(curX + 200, curY, 200, 20), XStringFormat.TopLeft);

            curY += 10;
            curY += 10;
            gfx.DrawString("Named Drivers", fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);
            curY += 15;
            gfx.DrawString("(A) THE INSURED", fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);

            int _AddLineCount = 3;
            if (_driverNameList != string.Empty)
            {
                string[] _ArrNameList = _driverNameList.Split(';');
                if (_ArrNameList.Length > 0)
                {
                    for (int i = 0; i < _ArrNameList.Length; i++)
                    {
                        if (i == 0)
                        {
                            gfx.DrawString("(B) " + _ArrNameList[i].ToUpper(), fontNormal, XBrushes.Black, new XRect(newX + 300, curY, 200, 20), XStringFormat.TopLeft);
                        }
                        else if (i == 1)
                        {
                            curY += 10;
                            _AddLineCount -= 1;
                            gfx.DrawString("(C) " + _ArrNameList[i].ToUpper(), fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);
                        }
                        else if (i == 2)
                        {
                            gfx.DrawString("(D) " + _ArrNameList[i].ToUpper(), fontNormal, XBrushes.Black, new XRect(newX + 300, curY, 200, 20), XStringFormat.TopLeft);
                        }
                        else if (i == 3)
                        {
                            curY += 10;
                            _AddLineCount -= 1;
                            gfx.DrawString("(E) " + _ArrNameList[i].ToUpper(), fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);
                        }
                        else if (i == 4)
                        {
                            gfx.DrawString("(F) " + _ArrNameList[i].ToUpper(), fontNormal, XBrushes.Black, new XRect(newX + 300, curY, 200, 20), XStringFormat.TopLeft);
                        }
                    }
                }
            }
            curY += 15;
            gfx.DrawString("The following clauses and endorsements apply to this risk", fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);
            curY += 10;
            newX += 5;

            if (_driverNameList != String.Empty)
            {
                gfx.DrawString("ADDITIONAL NAMED DRIVER", fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);
                curY += 10;
            }

            if (_typeOfCover.Trim() == "2") //Panel
            {
                gfx.DrawString("AUTHORISED WORKSHOPS SCHEME - FREE WINDSCREEN COVER, WITH NIL EXCESS SUBJECT TO REINSTATEMENT", fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);
                curY += 10;
            }

            gfx.DrawString("CONTRACTS (RIGHTS OF THIRD PARTIES) ACT 2001", fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);
            curY += 10;

            if (_isOFD)
            {
                gfx.DrawString("DEMERIT FREE DISCOUNT " + _ofdPercent, fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);
                curY += 10;
            }

            gfx.DrawString("ENDORSEMENT NO. MDP, MAP, M35, MGE", fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);
            curY += 10;

            gfx.DrawString("FLOOD &/OR OTHER CONVULSION OF NATURE AND STRIKE, RIOT & CIVIL COMMOTION", fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);
            curY += 10;

            gfx.DrawString("HIRE PURCHASE", fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString(_hirePurchaseCompanyName, fontNormal, XBrushes.Black, new XRect(curX + 200, curY, 200, 20), XStringFormat.TopLeft);
            curY += 10;

            gfx.DrawString("IT CLARIFICATION CLAUSE", fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);
            curY += 10;

            gfx.DrawString("LEGAL LIABILITY OF PASSENGERS FOR ACTS OF NEGLIGENCE", fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);
            curY += 10;
           
            if (_isNCDProtector)
            {
                gfx.DrawString("NCD PROTECTION PREMIUM", fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);
                curY += 10;
            }
            
            if (_lessNCDPercent != "0%")
            {
                gfx.DrawString("NO CLAIM DISCOUNT", fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);
                curY += 10;
            }

            if (_typeOfCover.Trim() == "0") //ANy Workshops
            {

                gfx.DrawString("NON-AUTHORISED WORKSHOPS - FREE WINDSCREEN COVER, WITH NIL EXCESS SUBJECT TO REINSTATEMENT", fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);
                curY += 10;
            }           

            gfx.DrawString("PASSENGER LIABILITY ", fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);
            curY += 10;         

            gfx.DrawString("SETTLEMENT BASED ON MARKET VALUE AT TIME OF LOSS", fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);
            curY += 10;
          
            gfx.DrawString("TERRORISM EXCLUSION ENDORSEMENT", fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);
            curY += 13;

            gfx.DrawString("Limits of liability applicable:", fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);
            curY += 10;

            gfx.DrawString("Item No. 2.3.1	Protection and removal after damage or loss", fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString(": S$200", fontNormal, XBrushes.Black, new XRect(newX + 250, curY, 200, 20), XStringFormat.TopLeft);
            curY += 10;

            gfx.DrawString("Item No. 2.3.2	Authority to repair", fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString(": S$300", fontNormal, XBrushes.Black, new XRect(newX + 250, curY, 200, 20), XStringFormat.TopLeft);
            curY += 10;

            gfx.DrawString("Item No. 3.1.1 (a) Legal liability for death or bodily injury", fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString(": Unlimited", fontNormal, XBrushes.Black, new XRect(newX + 250, curY, 200, 20), XStringFormat.TopLeft);
            curY += 10;

            gfx.DrawString("Item No. 3.1.1 (b) Legal liability for loss/damage to property", fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString(": S$5,000,000", fontNormal, XBrushes.Black, new XRect(newX + 250, curY, 200, 20), XStringFormat.TopLeft);
            curY += 10;

            gfx.DrawString("Item No. 3.1.2 	Legal representative and services", fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString(": S$2,000", fontNormal, XBrushes.Black, new XRect(newX + 250, curY, 200, 20), XStringFormat.TopLeft);
            curY += 10;

            gfx.DrawString("Item No. 4.1	Medical expenses", fontNormal, XBrushes.Black, new XRect(newX, curY, 200, 20), XStringFormat.TopLeft);
            gfx.DrawString(": S$200", fontNormal, XBrushes.Black, new XRect(newX + 250, curY, 200, 20), XStringFormat.TopLeft);
            curY += 10;

            curY += (3 * _AddLineCount) + 4;

            gfx.DrawLine(new XPen(_xcolor), curX, curY, 565, curY);
            curY += 10;

            gfx.DrawString("The following clauses and endorsement apply to this policy", fontNormal, XBrushes.Black, new XRect(curX, curY, 200, 20), XStringFormat.TopLeft);
            curY += 20;
            gfx.DrawString("GO GREEN MESSAGE", font, XBrushes.Black, new XRect(newX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawString("Visit www.etiqa.com.sg/policycontracts or our office to obtain the full policy wordings.", fontNormal, XBrushes.Black, new XRect(newX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 12;
            gfx.DrawString("Let's build a Clean and Green Singapore, please think before you print.", font, XBrushes.Black, new XRect(newX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 15;
            gfx.DrawString("Continued on page 2", fontNormal, XBrushes.Black, new XRect(curX + 410, curY, 200, 20), XStringFormat.TopLeft);

            //Page 2
            // Create an empty page
            PdfPage page2 = document.AddPage();

            // Get an XGraphics object for drawing
            XGraphics gfx2 = XGraphics.FromPdfPage(page2);

            curX = 50;
            curY = 30;

            gfx2.DrawImage(XImage.FromFile(AppDomain.CurrentDomain.BaseDirectory + "images\\pdf\\header_etiqa_01.png"), new XRect(curX, curY, 520, 61));
            curY += 65;

            gfx2.DrawString("ORIGINAL", font, XBrushes.Black, new XRect(curX, curY, 520, 20), XStringFormat.TopLeft);
            gfx2.DrawString("THE SCHEDULE", font, XBrushes.Black, new XRect(curX, curY, 520, 20), XStringFormat.TopCenter);
            gfx2.DrawString("Page 2", font, XBrushes.Black, new XRect(curX + 230, curY, 520, 20), XStringFormat.TopCenter);
            curY += 25;

            gfx2.DrawString("SUBJECT TO LOCAL JURISDICTION", font, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 25;
            gfx2.DrawString("NCD PROTECTION PREMIUM", font, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 10;
            gfx2.DrawString("It is hereby understood and agreed that the Company will at the request of the Insured who has accumulated 50% No Claim Discount (NCD)", fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 10;
            gfx2.DrawString("protect the 50% NCD entitlement in this Policy as follows:", fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 25;

            gfx2.DrawString("No. of claim made or arisen", fontNormal, XBrushes.Black, new XRect(curX + 50, curY, 500, 20), XStringFormat.TopLeft);
            gfx2.DrawString("NCD entitlement on renewal of the Policy", fontNormal, XBrushes.Black, new XRect(curX +300, curY, 500, 20), XStringFormat.TopLeft);
            curY += 10;

            gfx2.DrawString("during the period of insurance", fontNormal, XBrushes.Black, new XRect(curX + 50, curY, 500, 20), XStringFormat.TopLeft);
            curY += 10;

            gfx2.DrawString("----------------------------------------", fontNormal, XBrushes.Black, new XRect(curX + 50, curY, 500, 20), XStringFormat.TopLeft);
            gfx2.DrawString("-------------------------------------------------------", fontNormal, XBrushes.Black, new XRect(curX + 300, curY, 500, 20), XStringFormat.TopLeft);
            curY += 10;

            gfx2.DrawString("One", fontNormal, XBrushes.Black, new XRect(curX + 100, curY, 500, 20), XStringFormat.TopLeft);
            gfx2.DrawString("50%", fontNormal, XBrushes.Black, new XRect(curX + 375, curY, 500, 20), XStringFormat.TopLeft);
            curY += 10;

            gfx2.DrawString("Two", fontNormal, XBrushes.Black, new XRect(curX + 100, curY, 500, 20), XStringFormat.TopLeft);
            gfx2.DrawString("20%", fontNormal, XBrushes.Black, new XRect(curX + 375, curY, 500, 20), XStringFormat.TopLeft);
            curY += 10;

            gfx2.DrawString("Three", fontNormal, XBrushes.Black, new XRect(curX + 100, curY, 500, 20), XStringFormat.TopLeft);
            gfx2.DrawString("NIL", fontNormal, XBrushes.Black, new XRect(curX + 375, curY, 500, 20), XStringFormat.TopLeft);
            curY += 25;

            gfx2.DrawString("This No Claim Discount Protection is not applicable to cases involving the loss of NCD as a result of not reporting or late reporting of", font, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 10;
            gfx2.DrawString("accidents as set out under the Policy.", font, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 20;

            gfx2.DrawString("It is further hereby noted that this protected no claim discount entitlement is not transferable.", fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 25;

            gfx2.DrawString("PARALLEL IMPORTED VEHICLES", font, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 20;
            gfx2.DrawString("In the event of loss or damage to the vehicle and its accessories, the company shall not be liable", fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 10;
            gfx2.DrawString("To pay for any airfreight charges or any other costs arising out of the delay in the repairs as a ", fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 10;
            gfx2.DrawString("result of unavailability of the spare parts for parallel imported vehicles.", fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 25;


            gfx2.DrawString("COMPLAINT PROCEDURE", font, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 20;
            gfx2.DrawString("If you make a complaint to us, in order to expedite matters, you need to provide us with your details (name, contact numbers, etc), specific nature", fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 10;
            gfx2.DrawString("of your complaint and supporting documents.", fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 20;

            gfx2.DrawString("Stage One", fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 10;
            gfx2.DrawString("---------------", fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 10;
            gfx2.DrawString("1.    Acknowledge your complaint within 3 business days.", fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 10;
            gfx2.DrawString("2.    If we need additional information we will contact you and request that information within 7 business days of the date of your complaint.", fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 10;
            gfx2.DrawString("3.    We will endeavour to resolve all complaints as soon as possible. If your complaint takes longer to resolve, we will contact you and update", fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 10;
            gfx2.DrawString("      you on the progress on your complaint within 14 business days of our last communication to you.", fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 20;

            gfx2.DrawString("Stage Two", fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 10;
            gfx2.DrawString("---------------", fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 10;
            gfx2.DrawString("If the outcome of your complaint is not handled to your satisfaction, you can write to the Principal Officer of the insurance company to appeal. We", fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 10;
            gfx2.DrawString("will respond to your appeal within 14 business days.", fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 15;
            gfx2.DrawString("If you are still dissatisfied with the Principal Officer’s response, we will refer you to a dispute resolution organization, Financial Industry Disputes", fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 10;
            gfx2.DrawString("Resolution Centre Ltd (FIDReC), who acts independently of the insurer.", fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 40;

            gfx2.DrawString("Contact Details are:-", fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 15;
            gfx2.DrawString("Financial Industry Disputes Resolution Centre Ltd (FIDReC)", fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 10;
            gfx2.DrawString("112 Robinson Road #13-03", fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 10;
            gfx2.DrawString("HB Robinson", fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 10;
            gfx2.DrawString("Singapore 068902", fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 10;
            gfx2.DrawString("Telephone      :     63278878", fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 10;
            gfx2.DrawString("Fax               :     63278488", fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
            curY += 10;
            gfx2.DrawString("Email            :     info@fidrec.com.sg", fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 20), XStringFormat.TopLeft);
         
            curY += 60;
            gfx2.DrawString("Continued on page 3", fontNormal, XBrushes.Black, new XRect(curX + 410, curY, 200, 20), XStringFormat.TopLeft);

         

            //Etiqa_Schedule_writings_New.pdf
            HttpUtility _server = new HttpUtility();
            PdfDocument inputDocument = PdfReader.Open(AppDomain.CurrentDomain.BaseDirectory + "images\\pdf\\Etiqa_Schedule_writings_New.pdf", PdfDocumentOpenMode.Import);

            string _filePath = GetFilePath();
            string filename = _filePath + "Etiqa_Schedule_" + _proposalId + ".pdf";

            document.AddPage(inputDocument.Pages[1]);
            //document.AddPage(inputDocument.Pages[2]);
            //document.Save(filename);
            // ...and start a viewer.
            //Response.Redirect(filename);

            System.IO.MemoryStream stream = new System.IO.MemoryStream();
            document.Save(filename);
            stream.Close();
            document.Close();
            //Response.Redirect(filename);
            return filename;
        }

        public string EtiqaCertificateOutputSample()
        {
            // Create a new PDF document
            PdfDocument document = new PdfDocument();
            document.Info.Title = _certificatepagetitle;

            // Create an empty page
            PdfPage page = document.AddPage();

            // Get an XGraphics object for drawing
            XGraphics gfx = XGraphics.FromPdfPage(page);

            //XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);

            // Create a font
            XFont font = new XFont("Verdana", 10, XFontStyle.Bold);

            XColor _xcolor = new XColor();
            _xcolor.R = 0;
            _xcolor.G = 0;
            _xcolor.B = 0;
            System.Drawing.Rectangle _rect = new System.Drawing.Rectangle(20, 10, 500, 100);
            XPen _pen = new XPen(_xcolor);

            int curX = 40;
            int curY = 50;

            gfx.DrawImage(XImage.FromFile(AppDomain.CurrentDomain.BaseDirectory + "images\\pdf\\header_etiqa-insurance.png"), new XRect((page.Width / 2) - 60, curY, 120, 61));
            curY += 65;

            gfx.DrawString("CERTIFICATE OF INSURANCE", font, XBrushes.Black, new XRect(curX, curY, 50, 15), XStringFormat.TopLeft);
            curY += 15;
            XFont _fontNormal = new XFont("Verdana", 7, XFontStyle.Regular);
            gfx.DrawString("MOTOR VEHICLES (THIRD-PARTY RISKS AND COMPENSATION) ACT (CHAPTER 189). MOTOR VEHICLES (THIRD-PARTY RISKS AND COMPENSATION)", _fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 15), XStringFormat.TopLeft);
            curY += 8;
            gfx.DrawString("RULES, 1960. ROAD TRANSPORT ACT, 1987 (MALAYSIA) . MOTOR VEHICLES (THIRD-PARTY RISKS) RULES, 1959 (MALAYSIA).", _fontNormal, XBrushes.Black, new XRect(curX, curY, 510, 15), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawRoundedRectangle(new XPen(_xcolor), new XRect(curX, curY, 535, 450), new XSize(10, 10));

            curX += 8;
            curY += 15;
            int newX = curX + 150;
            int lineSeparator = 15;

            gfx.DrawString("CERTIFICATE No.", _fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 15), XStringFormat.TopLeft);
            gfx.DrawString(_certNumber, _fontNormal, XBrushes.Black, new XRect(newX, curY, 500, 15), XStringFormat.TopLeft);
            curY += 20;
            curX -= 8;
            gfx.DrawLine(new XPen(_xcolor), curX, curY, 575, curY);

            curX += 8;
            curY += 20;

            gfx.DrawString("1.  Index Mark and Registration", _fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 15), XStringFormat.TopLeft);
            gfx.DrawString(_registrationNo.ToUpper(), _fontNormal, XBrushes.Black, new XRect(newX, curY, 500, 15), XStringFormat.TopLeft);

            curX += 300;
            gfx.DrawString("Hire Purchase : ", _fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 15), XStringFormat.TopLeft);
            gfx.DrawString(_hirePurchaseCompanyName, _fontNormal, XBrushes.Black, new XRect(curX + 60, curY, 500, 15), XStringFormat.TopLeft);
            curX -= 300;

            curY += 10;
            gfx.DrawString("     Number of Vehicle", _fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 15), XStringFormat.TopLeft);
            curY += lineSeparator;

            gfx.DrawString("2.  Name of Policyholder", _fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 15), XStringFormat.TopLeft);
            gfx.DrawString(_customerName.ToUpper(), _fontNormal, XBrushes.Black, new XRect(newX, curY, 500, 15), XStringFormat.TopLeft);
            curY += lineSeparator;

            newX += 50;

            gfx.DrawString("3.  Effective Date of Commencement of Insurance", _fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 15), XStringFormat.TopLeft);
            gfx.DrawString(_startPeriod, _fontNormal, XBrushes.Black, new XRect(newX, curY, 500, 15), XStringFormat.TopLeft);

            newX -= 50;
            curX += 300;
            newX += 250;

            gfx.DrawString("Excess : Named Drivers", _fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 15), XStringFormat.TopLeft);
            gfx.DrawString(_excessNameDriverAmount, _fontNormal, XBrushes.Black, new XRect(newX, curY, 500, 15), XStringFormat.TopLeft);

            curX -= 300;
            newX -= 250;
            curY += 10;
            gfx.DrawString("     for the purposes of the Act", _fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 15), XStringFormat.TopLeft);

            curX += 300;
            newX += 250;

            gfx.DrawString("Excess : Unnamed Drivers", _fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 15), XStringFormat.TopLeft);
            gfx.DrawString(_excessUnNameDriverAmount, _fontNormal, XBrushes.Black, new XRect(newX, curY, 500, 15), XStringFormat.TopLeft);

            curX -= 300;
            newX -= 250;
            newX += 50;
            curY += lineSeparator;

            gfx.DrawString("4.  Date of Expiry of Insurance", _fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 15), XStringFormat.TopLeft);
            gfx.DrawString(_endPeriod, _fontNormal, XBrushes.Black, new XRect(newX, curY, 500, 15), XStringFormat.TopLeft);
            newX -= 50;
            newX -= 130;
            curY += lineSeparator;

            XFont _courierFont = new XFont("Courier", 6.2, XFontStyle.Regular);
            gfx.DrawString("5.  Persons or Classes of Persons entitled to drive", _fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 15), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawString("(A)  THE POLICYHOLDER.", _courierFont, XBrushes.Black, new XRect(newX, curY, 500, 15), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawString("       THE POLICYHOLDER MAY ALSO DRIVE A MOTOR CAR NOT BELONGING TO HIM OR HIRED (UNDER A HIRE PURCHASE", _courierFont, XBrushes.Black, new XRect(newX, curY, 500, 15), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawString("       AGREEMENT OR OTHERWISE) TO HIM OR HIS EMPLOYER OR HIS PARTNER.", _courierFont, XBrushes.Black, new XRect(newX, curY, 500, 15), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawString("(B)  ANY OTHER PERSON WHO IS DRIVING ON THE POLICYHOLDER'S ORDER OR WITH HIS PERMISSION.", _courierFont, XBrushes.Black, new XRect(newX, curY, 500, 15), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawString("(a) THE INSURED", _courierFont, XBrushes.Black, new XRect(newX + 20, curY, 500, 15), XStringFormat.TopLeft);
            
            int _AddLineCount = 6;
            if (_driverNameList != string.Empty)
            {
                string[] _ArrNameList = _driverNameList.Split(';');
                if (_ArrNameList.Length > 0)
                {
                    _AddLineCount -= _ArrNameList.Length;
                    for (int i = 0; i < _ArrNameList.Length; i++)
                    {
                        curY += 10;
                        if (i == 0)
                        {
                            gfx.DrawString("(b) " + _ArrNameList[i].ToUpper(), _courierFont, XBrushes.Black, new XRect(newX + 20, curY, 500, 15), XStringFormat.TopLeft);
                        }
                        else if (i == 1)
                        {
                            gfx.DrawString("(c) " + _ArrNameList[i].ToUpper(), _courierFont, XBrushes.Black, new XRect(newX + 20, curY, 500, 15), XStringFormat.TopLeft);
                        }
                        else if (i == 2)
                        {
                            gfx.DrawString("(d) " + _ArrNameList[i].ToUpper(), _courierFont, XBrushes.Black, new XRect(newX + 20, curY, 500, 15), XStringFormat.TopLeft);
                        }
                        else if (i == 3)
                        {
                            gfx.DrawString("(e) " + _ArrNameList[i].ToUpper(), _courierFont, XBrushes.Black, new XRect(newX + 20, curY, 500, 15), XStringFormat.TopLeft);
                        }
                        else if (i == 4)
                        {
                            gfx.DrawString("(f) " + _ArrNameList[i].ToUpper(), _courierFont, XBrushes.Black, new XRect(newX + 20, curY, 500, 15), XStringFormat.TopLeft);
                        }
                    }
                }
            }

            newX += 20;
            curY += lineSeparator;
            gfx.DrawString("Provided that the person driving is permitted in accordance with the licensing or other laws or regulations to", _fontNormal, XBrushes.Black, new XRect(newX, curY, 500, 15), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawString("drive the Motor Vehicle or has been so permitted and is not disqualified by order of a Court of Law or by reason", _fontNormal, XBrushes.Black, new XRect(newX, curY, 500, 15), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawString("of any enactment or regulation in that behalf from driving the Motor Vehicle.", _fontNormal, XBrushes.Black, new XRect(newX, curY, 500, 15), XStringFormat.TopLeft);
            curY += lineSeparator;
            curY += 5;

            gfx.DrawString("6.  Limitations as to Use", _fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 15), XStringFormat.TopLeft);
            curY += lineSeparator;
            newX -= 20;
            gfx.DrawString("USE ONLY FOR SOCIAL. DOMESTIC AND PLEASURE PURPOSES AND FOR THE POLICYHOLDER'S BUSINESS.", _courierFont, XBrushes.Black, new XRect(newX, curY, 500, 15), XStringFormat.TopLeft);
            curY += 20;

            gfx.DrawString("THE POLICY DOES NOT COVER:", _courierFont, XBrushes.Black, new XRect(newX, curY, 500, 15), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawString("(i)   USE FOR HIRE OR REWARD.", _courierFont, XBrushes.Black, new XRect(newX, curY, 500, 15), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawString("(ii)  USE FOR RACING. PACE-MARKING. RELIABILITY TRIAL OR SPEED-TESTING.", _courierFont, XBrushes.Black, new XRect(newX, curY, 500, 15), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawString("(iii) USE FOR THE CARRIAGE OF GOODS (OTHER THAN SAMPLES) IN CONNECTION WITH ANY TRADE OR BUSINESS.", _courierFont, XBrushes.Black, new XRect(newX, curY, 500, 15), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawString("(iv) USE FOR ANY PURPOSE IN CONNECTION WITH THE MOTOR TRADE.", _courierFont, XBrushes.Black, new XRect(newX, curY, 500, 15), XStringFormat.TopLeft);
            curY += 40 + (10 * _AddLineCount);

            gfx.DrawString("* Limitations rendered inoperative by Section 8 of the Motor Vehicles (Third-Party Risks and Compensation) Act (Chapter 189)", _fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 15), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawString("and Section 95 of the Road Transport Act, 1987 (Malaysia), are not to be included under these headings.", _fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 15), XStringFormat.TopLeft);
            curY += lineSeparator;
            curY += 10;
            //Bottom Text
            gfx.DrawString("I/WE HEREBY CERTIFY that the policy to which this Certificate relates is issued in accordance with the provisions of the Motor Vehicles (Third-Party ", _fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 15), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawString("Risks and Compensation) Act (Chapter 189) and Part IV of the Road Transport Act, 1987 (Malaysia).", _fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 15), XStringFormat.TopLeft);
                        
            curY += 15;
            XFont _fontBold = new XFont("Verdana", 7, XFontStyle.Bold);
            gfx.DrawString("Policy Owner's Protection Scheme", _fontBold, XBrushes.Black, new XRect(curX, curY, 500, 15), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawString("This policy is protected under the Policy Owners’ Protection Scheme which is administered by the Singapore Deposit Insurance Corporation (SDIC).", _fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 15), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawString("Coverage for your policy is automatic and no further action is required from you. For more information on the types of benefits that are covered", _fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 15), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawString("under the scheme as well as the limits of coverage, where applicable, please contact your insurer or visit the GIA / LIA or SDIC websites ", _fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 15), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawString("(www.gia.org.sg or www.lia.org.sg or www.sdic.org.sg).", _fontNormal, XBrushes.Black, new XRect(curX, curY, 500, 15), XStringFormat.TopLeft);

            curY += lineSeparator;

            curY += lineSeparator;
            newX += 270;
            gfx.DrawString("For and on behalf of Etiqa Insurance Berhad", _fontNormal, XBrushes.Black, new XRect(newX, curY, 300, 15), XStringFormat.TopCenter);
            curY += 10;
            gfx.DrawString("Approved Insurer", _fontNormal, XBrushes.Black, new XRect(newX, curY, 300, 15), XStringFormat.TopCenter);
            curY += 20;
            gfx.DrawImage(XImage.FromFile(AppDomain.CurrentDomain.BaseDirectory + "images\\pdf\\etiqa_signature.jpg"), newX + 110, curY, 80, 40);
            curY += 25;
            curY += lineSeparator;

            gfx.DrawString("Authorised Signature", _fontNormal, XBrushes.Black, new XRect(newX, curY, 300, 15), XStringFormat.TopCenter);
            curY += lineSeparator;

          



            string _filePath = GetFilePath();
            string filename = _filePath + "Etiqa_CarInsurance_Certificate_" + _proposalId + ".pdf";
            //document.Save(filename);
            // ...and start a viewer.
            //Response.Redirect(filename);
            System.IO.MemoryStream stream = new System.IO.MemoryStream();
            document.Save(filename);
            stream.Close();
            document.Close();
            return filename;
            //Response.Redirect(filename);
        }

        public string EtiqaTaxInvoiceOutputSample()
        {
            // Create a new PDF document
            PdfDocument document = new PdfDocument();
            document.Info.Title = _taxinvoicepagetitle;

            // Create an empty page
            PdfPage page = document.AddPage();

            // Get an XGraphics object for drawing
            XGraphics gfx = XGraphics.FromPdfPage(page);

            //XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);

            // Create a font
            XFont font = new XFont("Verdana", 10, XFontStyle.Bold);

            XColor _xcolor = new XColor();
            _xcolor.R = 0;
            _xcolor.G = 0;
            _xcolor.B = 0;
            System.Drawing.Rectangle _rect = new System.Drawing.Rectangle(20, 10, 500, 100);
            XPen _pen = new XPen(_xcolor);

            int curX = 50;
            int curY = 50;

            gfx.DrawImage(XImage.FromFile(AppDomain.CurrentDomain.BaseDirectory + "images\\pdf\\header_etiqa_01.png"), new XRect(curX, curY, 520, 61));
            curY += 65;

         
            int _boxWidth = Convert.ToInt32(page.Width.Value) - 100;

            DrawBoxWithText(gfx, _xcolor, curX, curY, _boxWidth, 20, 0.8d, "TAX INVOICE", "Verdana", 10.0d, XFontStyle.Bold);
            curY += 25;

            _xcolor.R = 255;
            _xcolor.G = 255;
            _xcolor.B = 255;

            DrawBoxWithText(gfx, _xcolor, curX, curY, _boxWidth, 20, 0, "Debit Note", "Verdana", 10.0d, XFontStyle.Bold);
            curY += 20;

            XFont _textFont = new XFont("Verdana", 8, XFontStyle.Bold);
            gfx.DrawString("GST Reg. No. " + _gstRegNumber, _textFont, XBrushes.Black, new XRect(curX, curY, 50, 15), XStringFormat.TopLeft);
            gfx.DrawString("Invoice Date : " + _transDate, _textFont, XBrushes.Black, new XRect(curX + 330, curY, 50, 15), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawString("Invoice Number : CX" + _policyNumber, _textFont, XBrushes.Black, new XRect(curX + 330, curY, 50, 15), XStringFormat.TopLeft);
            curY += 30;

            gfx.DrawString(_customerName, _textFont, XBrushes.Black, new XRect(curX + 30, curY, 50, 15), XStringFormat.TopLeft);
            curY += 10;

            string _tmpAddress1 = "";
            string[] _addresslist = _customerAddress1.Split(',');
            for (int _d = 0; _d < _addresslist.Length - 1; _d++)
            {
                if (_d == 0 || _d == 1)
                {
                    //gfx.DrawString(_addresslist[_d] + ", " , _textFont, XBrushes.Black, new XRect(curX + 30, curY, 50, 15), XStringFormat.TopLeft);
                    _tmpAddress1 += _addresslist[_d] + ", ";
                    curY += 10;
                }
                else if (_d == 2)
                {
                    _customerAddress2 = _addresslist[_d].Trim() + ", " + _customerAddress2;
                }
                else
                {
                    break;
                }
            }
            _customerAddress1 = _tmpAddress1;

            gfx.DrawString(_customerAddress1, _textFont, XBrushes.Black, new XRect(curX + 30, curY, 50, 15), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawString(_customerAddress2, _textFont, XBrushes.Black, new XRect(curX + 30, curY, 50, 15), XStringFormat.TopLeft);
            curY += 30;
            
            string[,] _arrNewData = new string[,]{{"Type Of Policy", _classOfPolicy},
                           {"Vehicle Number", _registrationNo},
                          {"Policy Number", _policyNumber},
                          {"Period of Cover", "From " + _startPeriod + " to " + _endPeriod + "(both dates inclusive)"},
                          {"Main Insured's Name", _customerName},
                          {"Insured's Address", _customerAddress1},
                          {"", _customerAddress2},
        {"Branch / Territory",_branchTerritory}};

            int[] _colArrWidth = { 180, 300 };

            _xcolor.R = 0;
            _xcolor.G = 0;
            _xcolor.B = 0;

            DrawBoxWithTextList(gfx, _xcolor, curX, curY, _boxWidth, 12, 7, 2, 1.0d, "Verdana", 10, XFontStyle.Regular, _arrNewData, _colArrWidth);

            curY += 180;

            if (_20percentpromo != "" && _20percentpromo == "20discount")
            {
                string[,] _arrPremiumData = new string[,]{{"Annual Premium (Inclusive of 7% GST)", "           S$        " + String.Format("{0:0,0.00}", Convert.ToSingle(_totalDueInvoice))},
                            {"20% FESTIVE PROMO discount", "           S$        "+ _promodiscount.Remove(0,3)},
                            {"", "_________________________"},
                            {"Total Due", "           S$        "+_discountedpremium.Remove(0,3)},
                          };

                _xcolor.R = 0;
                _xcolor.G = 0;
                _xcolor.B = 0;
                int[] _colPremiumArrWidth = { 300, 150 };
                DrawBoxWithTextList(gfx, _xcolor, curX, curY, _boxWidth, 10, 4, 2, 1.0d, "Verdana", 10, XFontStyle.Regular, _arrPremiumData, _colPremiumArrWidth);

            }
            else
            {
                string[,] _arrPremiumData = new string[,]{{"Annual Premium (Inclusive of 7% GST)", "           S$        "+_totalDueInvoice},{"", "_________________________"},
                          {"Total Due", "           S$        "+_totalDueInvoice},
                          };

                _xcolor.R = 0;
                _xcolor.G = 0;
                _xcolor.B = 0;
                int[] _colPremiumArrWidth = { 300, 150 };
                DrawBoxWithTextList(gfx, _xcolor, curX, curY, _boxWidth, 10, 3, 2, 1.0d, "Verdana", 10, XFontStyle.Regular, _arrPremiumData, _colPremiumArrWidth);

            }
            
            curY += 90;
            gfx.DrawString("Paid via " + _cardType + " XXXX XXXX XXXX XXXX" + _cardLastFourDigit, _textFont, XBrushes.Black, new XRect(curX, curY, 50, 15), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawString("Signed for and on behalf of the company", _textFont, XBrushes.Black, new XRect(curX, curY, 50, 15), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawImage(XImage.FromFile(AppDomain.CurrentDomain.BaseDirectory + "images\\pdf\\etiqa_signature.jpg"), curX + 50, curY, 80, 40);
            curY += 35;
            gfx.DrawString("_______________________________", _textFont, XBrushes.Black, new XRect(curX, curY, 50, 15), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawString("Authorized Signature", _textFont, XBrushes.Black, new XRect(curX, curY, 50, 15), XStringFormat.TopLeft);

            string _filePath = GetFilePath();
            string filename = _filePath + "Etiqa_TaxInvoice_" + _proposalId + ".pdf";
            //document.Save(filename);
            // ...and start a viewer.
            //Response.Redirect(filename);
            System.IO.MemoryStream stream = new System.IO.MemoryStream();
            document.Save(filename);
            stream.Close();
            document.Close();
            //Response.Redirect(filename);
            return filename;
        }

        private void DrawBoxWithText(XGraphics _objG, XColor _xcolor, int x, int y, int width, int height, double borderWidth, string strText, string strFontName, double fontSize, XFontStyle xFontStyle)
        {
            //System.Drawing.Rectangle _rect = new System.Drawing.Rectangle(0, 0, 0, 0);
            XRect _rect = new XRect(0, 0, 0, 0);
            _rect.X = x;
            _rect.Y = y;
            _rect.Width = width;
            _rect.Height = height;
            XPen _pen = new XPen(_xcolor);
            _pen.Width = borderWidth;
            XFont font = new XFont(strFontName, fontSize, xFontStyle);
            _objG.DrawRectangle(_pen, _rect);
            _objG.DrawString(strText, font, XBrushes.Black, _rect, XStringFormats.Center);
        }

        private void DrawBoxWithTextList(XGraphics _objG, XColor _xcolor, int x, int y, int width, int height, int rows, int cols, double borderWidth, string strFontName, double fontSize, XFontStyle xFontStyle, string[,] _arrData, int[] _arrColsWidth)
        {
            //System.Drawing.Rectangle _rect = new System.Drawing.Rectangle(0, 0, 0, 0);
            XRect _rect = new XRect(0, 0, 0, 0);
            _rect.X = x;
            _rect.Y = y;
            _rect.Width = width;
            _rect.Height = (height + 8) * rows;

            XColor _xOuterBoxColor = new XColor();
            _xOuterBoxColor.R = 0;
            _xOuterBoxColor.G = 0;
            _xOuterBoxColor.B = 0;

            XPen _pen = new XPen(_xcolor);
            _pen.Width = borderWidth;
            XFont font = new XFont(strFontName, fontSize, xFontStyle);
            XFont boldFont = new XFont(strFontName, fontSize, XFontStyle.Bold);
            _objG.DrawRectangle(_pen, _rect);

            //System.Drawing.Rectangle _rectText = new System.Drawing.Rectangle(0, 0, 0, 0);
            XRect _rectText = new XRect(0, 0, 0, 0);
            _rectText.X = x + 5;
            _rectText.Y = y + 5;
            _rectText.Width = width;
            _rectText.Height = height;

            for (int i = 0; i < rows; i++)
            {
                // Draw the text
                for (int j = 0; j < cols; j++)
                {
                    _rectText.Width = _arrColsWidth[j];
                    if (j == 0)
                    {
                        _objG.DrawString(_arrData[i, j].ToString(), boldFont, XBrushes.Black, _rectText, XStringFormats.TopLeft);
                    }
                    else
                    {
                        _objG.DrawString(_arrData[i, j].ToString(), font, XBrushes.Black, _rectText, XStringFormats.TopLeft);
                    }
                    _rectText.X += _arrColsWidth[j];
                }
                _rectText.X = x + 5;
                _rectText.Y += height + 5;
            }

        }

        private void DrawTable(XGraphics _objG, int x, int y, int rows, int cols, int rowHeight, int[] _arrColsWidth, string[] _arrHeader, string[,] _arrData)
        {
            XColor _xcolor = new XColor();
            _xcolor.R = 0;
            _xcolor.G = 0;
            _xcolor.B = 0;
            //System.Drawing.Rectangle _rect = new System.Drawing.Rectangle(0, 0, 0, 0);
            XRect _rect = new XRect(0, 0, 0, 0);
            _rect.X = x;
            _rect.Y = y;
            _rect.Width = _arrColsWidth[0];
            _rect.Height = rowHeight;
            XPen _pen = new XPen(_xcolor);
            _pen.Width = 0.5d;
            XFont font = new XFont("Verdana", 5, XFontStyle.Regular);

            for (int h = 0; h < cols; h++)
            {
                _rect.Width = _arrColsWidth[h];
                _objG.DrawRectangle(_pen, _rect);
                _objG.DrawString(_arrHeader[h].ToString(), font, XBrushes.Black,
          new XRect(_rect.X + 3, _rect.Y + 3, 10, 10),
          XStringFormats.TopLeft);
                _rect.X += _arrColsWidth[h];
            }

            _rect.Y += rowHeight;
            _rect.X = x;

            for (int i = 0; i < rows; i++)
            {
                // Draw the text
                for (int j = 0; j < cols; j++)
                {
                    _rect.Width = _arrColsWidth[j];

                    _objG.DrawRectangle(_pen, _rect);
                    _objG.DrawString(_arrData[i, j].ToString(), font, XBrushes.Black,
              new XRect(_rect.X + 3, _rect.Y + 3, 10, 10),
              XStringFormats.TopLeft);
                    _rect.X += _arrColsWidth[j];
                }
                _rect.Y += rowHeight;
                _rect.X = x;
            }
        }

        public void ClearFields()
        {
            _proposalId = "";
            _schedulewritingpagetitle = "Etiqa - Schedule Writing";// "Etiqa - Schedule Writing
            _certificatepagetitle = "Etiqa - Certificate Of Insurance";// "Etiqa - Certificate Of Insurance
            _taxinvoicepagetitle = "Etiqa - Tax";// "Etiqa - Tax

            #region Customer Profile
            _customerName = "";// "BRYAN YU CHEE SIANG
            _customerAddress1 = "";// "123, JALAN 222
            _customerAddress2 = "";// "SINGAPORE 604565
            #endregion

            #region Schedule Writing Variables
            _agency = "";// "001045
            _classOfPolicy = "";// "MOTOR PRIVATE CAR
            _policyNumber = "";// "DMAP105004354
            _account = "";// "001045
            _issuedOn = "";// DateTime.Now.Day.ToString("00") + "/" + DateTime.Now.Month.ToString("00") + "/" + DateTime.Now.Year.ToString("0000") + " in SINGAPORE
            _replacePolicyNumber = "";// "DMAP095006346
            _client = "";// "
            _acceptanceDate = "";// DateTime.Now.Day.ToString("00") + "/" + DateTime.Now.Month.ToString("00") + "/" + DateTime.Now.Year.ToString("0000")="";
            _basicPremiumAmount = "";// "S$1,529.55
            _lessNCDPercent = "";// "50.00%
            _lessNCDAmount = "";// "S$764.78-
            _ncdProtectionPremiumPercent = "";// "10%
            _ncdProtectionPremiumAmount = "";// "S$76.48
            _totalAnnualPermium = "";// "S$841.25
            _premiumDue = "";// "S$841.25
            _premiumGST = "";// "S$58.89
            _totalDueInvoice = "";// "S$900.14
            _totalDueSchedule = "";// "S$900.14
            _occupation = "";// "INDOOR - IT
            _registrationNo = "";// "SGU5007E
            _makeModel = "";// "MITSUBISHI LANCER 1.6M
            _typeOfCover = "";// "Comprehensive
            _noOfSeats = "";// "5
            _bodyType = "";// "SALOON
            _engineNo = "";// "4G18HY9061
            _capacity = "";// "1584
            _regYear = "";// "2007
            _chassisNo = "";// "JMYSNCS3A7U006848
            _certificateRef = "";// "MX1
            _excessNameDriverAmount = "";// "S$500.00
            _excessUnNameDriverAmount = "";// "S$1,000.00
            _hirePurchaseCompanyName = "";
            #endregion

            #region Certificate Variables
            _certNumber = "";// "DMAP10S004354

            #endregion

            #region Tax Invoice Variables
            _gstRegNumber = "";// "M90363266Y

            _transDate = "";// DateTime.Now.ToShortDateString()="";

            _branchTerritory = "";// "SINGAPORE / Singapore

            _cardType = "";

            _cardLastFourDigit = "";
            #endregion
        }

        private string GetFilePath()
        {
            string _filePath = CE.Configuration.MyConfigurationManager.GetAppSettingValue("FileOutputPath").ToString();
            _filePath += "pdfoutput\\etiqa\\";
            CE.InputOut.MyIO _myIO = new CE.InputOut.MyIO();
            string _todaydate = dateTimeNow.ToString("yyyyMMMdd"); //DateTime.Now.ToString("yyyyMMMdd");
            if (!_myIO.CheckDirectory(_filePath + _todaydate))
            {
                if (_myIO.CreateDirectory(_filePath, _todaydate))
                {
                    _filePath += _todaydate + "\\";
                }
            }
            else
            {
                _filePath += _todaydate + "\\";
            }

            return _filePath;
        }
    }
}
